/*
 * Copyright 2006-2008 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.martinimix.domain.payment;

import java.util.Calendar;

/**
 * Provides a <a href="http://www.bill-me-later.com/">Bill Me Later</a>
 * line of credit account.
 * 
 * Bill Me Later accounts are handled similarly to
 * credit card accounts; therefore, this class
 * extends <code>CreditCard</code>.
 * 
 * @author Scott Rossillo
 *
 */
public class BillMeLaterAccount extends CreditCard implements PaymentMethod {

	private static final long serialVersionUID = 1L;
	
	private Calendar dateOfBirth;
	private String socialSecurityNumber;
	
	private boolean agreedToTermsAndConditions;
	private String termsAndConditionsVersion;
	
	/**
	 * Creates a new Bill Me Later account.
	 */
	public BillMeLaterAccount() {
		super();
		this.agreedToTermsAndConditions = false;
		super.setBrand("BML");
	}
	
	/**
	 * Creates a copy of the given Bill Me Later account.
	 * 
	 * @param account the <code>BillMeLaterAccount</code>
	 * to create a copy of
	 */
	protected BillMeLaterAccount(BillMeLaterAccount account) {
		
		super(account);
		
		this.dateOfBirth = account.dateOfBirth;
		this.agreedToTermsAndConditions = account.agreedToTermsAndConditions;
		this.socialSecurityNumber = account.socialSecurityNumber;
	}

	public Calendar getDateOfBirth() {
		return dateOfBirth;
	}

	public void setDateOfBirth(Calendar dateOfBirth) {
		this.dateOfBirth = dateOfBirth;
	}

	public String getSocialSecurityNumber() {
		return socialSecurityNumber;
	}

	public void setSocialSecurityNumber(String socialSecurityNumber) {
		this.socialSecurityNumber = socialSecurityNumber;
	}

	public boolean isAgreedToTermsAndConditions() {
		return agreedToTermsAndConditions;
	}

	public void setAgreedToTermsAndConditions(boolean agreedToTermsAndConditions) {
		this.agreedToTermsAndConditions = agreedToTermsAndConditions;
	}

	/**
	 * Ignores request to set this account' brand.  Bill Me Later brand is always BML.
	 * 
	 * @see net.martinimix.domain.payment.CreditCard#setBrand(java.lang.String)
	 */
	public final void setBrand(String brand) { /* Do not allow brand to be changed */ }

	public String getTermsAndConditionsVersion() {
		return termsAndConditionsVersion;
	}

	public void setTermsAndConditionsVersion(String termsAndConditionsVersion) {
		this.termsAndConditionsVersion = termsAndConditionsVersion;
	}

	/* (non-Javadoc)
	 * @see net.martinimix.domain.payment.CreditCard#toString()
	 */
	public String toString() {
		
		final StringBuffer buf = new StringBuffer(256);
		
		buf.append("BillMeLaterAccount[");
		buf.append("id=").append(this.getId());
		buf.append(", usa_id=").append(this.getCustomerId());
		buf.append(']');
		
		return buf.toString();
	}

}
